import Cookies from 'js-cookie'

const TokenKey = 'authorization'
const userInfoManage = 'userinfomanage';
const userInfoBean = 'userinfobean'
const userName = 'username'

/**
 * 
 * @returns token
 */

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

/**
 * 
 * @returns 用户姓名
 */

export function getName() {
  return Cookies.get(userName)
}

export function setName(name) {
  return Cookies.set(userName, name)
}

export function removeName() {
  return Cookies.remove(userName)
}


/**
 * 
 * @returns 用户全部信息
 */

// export function getUserInfoManage() {
//   return Cookies.get(userInfoManage);
// }

// export function setUserInfoManage(info) {
//   return Cookies.set(userInfoManage, info);
// }

// export function removeUserInfoManage() {
//   return Cookies.remove(userInfoManage);
// }

export function getUserInfoManage() {
  return sessionStorage.getItem(userInfoManage)
}


export function setUserInfoManage(info) {
  return sessionStorage.setItem(userInfoManage, info) 
}

export function removeUserInfoManage() {
  return sessionStorage.setItem(userInfoManage, null)
}


/**
 *
 * @returns 用户基础信息  
 */

export function setUserInfoBean(info) {
  return Cookies.set(userInfoBean, info);
}

export function getUserInfoBean() {
  return Cookies.get(userInfoBean) ? Cookies.get(userInfoBean) : '{}'
}

export function removeUserInfoBean() {
  return Cookies.remove(userInfoBean)
}